From bdcb6b1341148796ebc09b7f0d75c838695342d6 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Mon, 25 Sep 2023 07:48:19 -0600 Subject: [PATCH] Remove final remnants of 'exported' (#1146) * Remove final remnants of 'exported' * incorporate review comments in duplicate filter, and remove deleted exported keyword from unicsv doc. --------- Co-authored-by: Robert Lipe --- duplicate.cc | 47 ++------------------------ geocache.h | 1 - gpx.cc | 5 --- reference/duplicate_exported_1.csv | 5 --- reference/duplicate_exported_1~csv.csv | 3 -- reference/duplicate_exported_2.csv | 5 --- reference/duplicate_exported_2~csv.csv | 3 -- testo.d/duplicate.test | 5 --- unicsv.cc | 23 ------------- unicsv.h | 1 - xmldoc/formats/unicsv.xml | 1 - 11 files changed, 2 insertions(+), 97 deletions(-) delete mode 100644 reference/duplicate_exported_1.csv delete mode 100644 reference/duplicate_exported_1~csv.csv delete mode 100644 reference/duplicate_exported_2.csv delete mode 100644 reference/duplicate_exported_2~csv.csv diff --git a/duplicate.cc b/duplicate.cc index dccfad848..252c068e9 100644 --- a/duplicate.cc +++ b/duplicate.cc @@ -21,52 +21,16 @@ #include "duplicate.h" -#include // for stable_sort - -#include // for QDateTime #include // for QList, QList<>::iterator, QList<>::const_iterator #include // for QMultiHash +#include // for qAsConst #include "defs.h" -#include "geocache.h" // for Geocache -#include "src/core/datetime.h" // for DateTime #if FILTERS_ENABLED #define MYNAME "duplicate" -/* - -It looks odd that we have different comparisons for date and index. - If exported if a < b return 1 - if index if a < b return -1 - -The reason is that we want to sort in reverse order by date, but forward -order by index. So if we have four records: - - date index - June 24 0 - June 25 1 - June 25 2 - June 24 3 - -we want to sort them like this: - - date index - June 25 1 - June 25 2 - June 24 0 - June 24 3 - -Thus, the first point we come across is the latest point, but if we -have two points with the same export date/time, we will first see the -one with the smaller index (i.e. the first of those two points that we -came across while importing waypoints.) - -In the (common) case that we have no exported dates, the dates will all -be zero so the sort will end up being an expensive no-op. However, the -complexity of this filter is dominated by other concerns. -*/ void DuplicateFilter::init() { @@ -77,15 +41,8 @@ void DuplicateFilter::init() void DuplicateFilter::process() { - auto wptlist = *global_waypoint_list; - - auto compare_lambda = [](const Waypoint* wa, const Waypoint* wb)->bool { - return wa->gc_data->exported > wb->gc_data->exported; - }; - std::stable_sort(wptlist.begin(), wptlist.end(), compare_lambda); - QMultiHash wpthash; - for (Waypoint* waypointp : wptlist) { + for (Waypoint* waypointp : qAsConst(*global_waypoint_list)) { QString key; if (lcopt) { diff --git a/geocache.h b/geocache.h index 25c491319..e53cc7193 100644 --- a/geocache.h +++ b/geocache.h @@ -114,7 +114,6 @@ public: status_t is_available:2; status_t is_memberonly:2; status_t has_customcoords:2; - gpsbabel::DateTime exported; gpsbabel::DateTime last_found; QString placer; /* Placer name */ int placer_id; /* Placer id */ diff --git a/gpx.cc b/gpx.cc index cf404ed60..9b8c8738f 100644 --- a/gpx.cc +++ b/gpx.cc @@ -1080,11 +1080,6 @@ GpxFormat::fprint_xml_chain(XmlTag* tag, const Waypoint* wpt) const if (tag->child) { fprint_xml_chain(tag->child, wpt); } - if (wpt && wpt->gc_data->exported.isValid() && - tag->tagname.compare(u"groundspeak:cache") == 0) { - writer->writeTextElement(QStringLiteral("time"), - wpt->gc_data->exported.toPrettyString()); - } writer->writeEndElement(); } if (!tag->parentcdata.isEmpty()) { diff --git a/reference/duplicate_exported_1.csv b/reference/duplicate_exported_1.csv deleted file mode 100644 index 4f413592a..000000000 --- a/reference/duplicate_exported_1.csv +++ /dev/null @@ -1,5 +0,0 @@ -No,Latitude,Longitude,Name,Exported -1,40.0,-105.1,"zero",2015/06/24 00:00:00 -1,40.0,-105.2,"one",2015/06/25 00:00:01 -1,40.0,-105.2,"two",2015/06/25 00:00:00 -1,40.0,-105.1,"three",2015/06/24 00:00:01 diff --git a/reference/duplicate_exported_1~csv.csv b/reference/duplicate_exported_1~csv.csv deleted file mode 100644 index bc70f1dfa..000000000 --- a/reference/duplicate_exported_1~csv.csv +++ /dev/null @@ -1,3 +0,0 @@ -No,Latitude,Longitude,Name,Exported -1,40.000000,-105.200000,"one","2015/06/25 00:00:01" -2,40.000000,-105.100000,"three","2015/06/24 00:00:01" diff --git a/reference/duplicate_exported_2.csv b/reference/duplicate_exported_2.csv deleted file mode 100644 index f3f657e9e..000000000 --- a/reference/duplicate_exported_2.csv +++ /dev/null @@ -1,5 +0,0 @@ -No,Latitude,Longitude,Name,Exported -1,40.0,-105.1,"zero",2015/06/24 00:00:02 -1,40.0,-105.2,"one",2015/06/25 00:00:01 -1,40.0,-105.2,"two",2015/06/25 00:00:02 -1,40.0,-105.1,"three",2015/06/24 00:00:01 diff --git a/reference/duplicate_exported_2~csv.csv b/reference/duplicate_exported_2~csv.csv deleted file mode 100644 index 9bd123f45..000000000 --- a/reference/duplicate_exported_2~csv.csv +++ /dev/null @@ -1,3 +0,0 @@ -No,Latitude,Longitude,Name,Exported -1,40.000000,-105.100000,"zero","2015/06/24 00:00:02" -2,40.000000,-105.200000,"two","2015/06/25 00:00:02" diff --git a/testo.d/duplicate.test b/testo.d/duplicate.test index ff8aaa5e4..c6dad28ab 100644 --- a/testo.d/duplicate.test +++ b/testo.d/duplicate.test @@ -7,8 +7,3 @@ gpsbabel -i geo -f ${REFERENCE}/geocaching.loc -o csv -F ${TMPDIR}/filterdupe.cs gpsbabel -i geo -f ${REFERENCE}/geocaching.loc -f ${REFERENCE}/geocaching.loc -x duplicate,shortname \ -o csv -F ${TMPDIR}/filterdupe.csv2 sort_and_compare ${TMPDIR}/filterdupe.csv1 ${TMPDIR}/filterdupe.csv2 - -gpsbabel -i unicsv,utc -f ${REFERENCE}/duplicate_exported_1.csv -x duplicate,location -o unicsv,utc -F ${TMPDIR}/duplicate_exported_1~csv.csv -compare ${REFERENCE}/duplicate_exported_1~csv.csv ${TMPDIR}/duplicate_exported_1~csv.csv -gpsbabel -i unicsv,utc -f ${REFERENCE}/duplicate_exported_2.csv -x duplicate,location -o unicsv,utc -F ${TMPDIR}/duplicate_exported_2~csv.csv -compare ${REFERENCE}/duplicate_exported_2~csv.csv ${TMPDIR}/duplicate_exported_2~csv.csv diff --git a/unicsv.cc b/unicsv.cc index 372fd016d..92ca85043 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -156,7 +156,6 @@ const UnicsvFormat::field_t UnicsvFormat::fields_def[] = { { "diff", fld_gc_diff, kStrAny }, { "arch", fld_gc_is_archived, kStrAny }, { "avail", fld_gc_is_available, kStrAny }, - { "exported", fld_gc_exported, kStrAny }, { "found", fld_gc_last_found, kStrAny }, { "placer_id", fld_gc_placer_id, kStrAny }, { "placer", fld_gc_placer, kStrAny }, @@ -869,7 +868,6 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf) case fld_gc_diff: case fld_gc_is_archived: case fld_gc_is_available: - case fld_gc_exported: case fld_gc_last_found: case fld_gc_placer: case fld_gc_placer_id: @@ -907,14 +905,6 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf) case fld_gc_is_available: gc_data->is_available = unicsv_parse_status(value); break; - case fld_gc_exported: { - QTime etime; - QDate edate; - etime = unicsv_parse_time(value, edate); - if (edate.isValid() || etime.isValid()) { - gc_data->exported = unicsv_adjust_time(edate, etime, true); - } - } break; case fld_gc_last_found: { QTime ftime; @@ -1251,9 +1241,6 @@ UnicsvFormat::unicsv_waypt_enum_cb(const Waypoint* wpt) if (gc_data->is_available != Geocache::status_t::gs_unknown) { unicsv_outp_flags[fld_gc_is_available] = true; } - if (gc_data->exported.isValid()) { - unicsv_outp_flags[fld_gc_exported] = true; - } if (gc_data->last_found.isValid()) { unicsv_outp_flags[fld_gc_last_found] = true; } @@ -1621,13 +1608,6 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt) *fout << unicsv_fieldsep; } } - if (unicsv_outp_flags[fld_gc_exported]) { - if (gc_data) { - unicsv_print_date_time(gc_data->exported); - } else { - *fout << unicsv_fieldsep; - } - } if (unicsv_outp_flags[fld_gc_last_found]) { if (gc_data) { unicsv_print_date_time(gc_data->last_found); @@ -1900,9 +1880,6 @@ UnicsvFormat::write() if (unicsv_outp_flags[fld_gc_is_available]) { *fout << unicsv_fieldsep << "Available"; } - if (unicsv_outp_flags[fld_gc_exported]) { - *fout << unicsv_fieldsep << "Exported"; - } if (unicsv_outp_flags[fld_gc_last_found]) { *fout << unicsv_fieldsep << "Last Found"; } diff --git a/unicsv.h b/unicsv.h index 021e65a89..a8c86664e 100644 --- a/unicsv.h +++ b/unicsv.h @@ -133,7 +133,6 @@ private: fld_gc_diff, fld_gc_is_archived, fld_gc_is_available, - fld_gc_exported, fld_gc_last_found, fld_gc_placer, fld_gc_placer_id, diff --git a/xmldoc/formats/unicsv.xml b/xmldoc/formats/unicsv.xml index bad010fdf..297a81a98 100644 --- a/xmldoc/formats/unicsv.xml +++ b/xmldoc/formats/unicsv.xml @@ -29,7 +29,6 @@ diff = Geocache difficulty ele = Elevation (in meters). For feet use "ele ft", "eleft", "ele feet", or "elefeet". e/w = 'e' for eastern hemisphere, 'w' for western - exported = Geocache export date found = Geocache last found date fix = 3d, 2d, etc. gcid = Geocache cache id. This accepts GC-ID ("575006") and GC-Code ("GC1234G"). -- 2.30.2